package top.z.orm.handle.osql.core;

import static top.z.orm.core.osql.SqlKeyWord.COUNT;

public final class SqlStrFilter {

    public static boolean checkFunSql(String sql, String funType) {
        sql = sql.trim().toLowerCase();
        funType = funType.trim().toLowerCase();
        if (COUNT.equalsIgnoreCase(funType) || funType.length() == 3) {

        } else {
            return true;
        }
        // select avg( 之间只能存在空格
        int a = sql.indexOf("select");
        int b = sql.indexOf(funType, a);
        if ("".equals(sql.substring(a + 6, b).trim())) {
            int c = sql.indexOf("(", b);
            return !"".equals(sql.substring(b + funType.length(), c).trim());
        }
        return true;
    }
}